<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <!--头部固定引用-->
  <meta charset="utf-8">
  <meta name="full-screen" content="yes">
  <meta name="x5-fullscreen" content="true">
  <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
  <link rel="stylesheet" href="../../css/base.css">
  <link rel="stylesheet" href="../../css/commentDetail.css">
  <!--固定引用结束,自定义引用添加在下面-->
  <title>快讯详情</title>
  <!--页面样式添加在这里，多看看base。css里面的公共样式，大部分常用的都有，避免使用独立css文件为单独页面设置样式，避免随意添加样式到公共样式-->
  <style>
      /* 头部 */
      .newsflash-details-header .header-left{
          position:absolute;
          left: 0.32rem;
          width: 0.32rem;
          height: 0.32rem;
      }
      .newsflash-details-header .header-left img{
          width: 0.32rem;
          height: 0.32rem;
      }
      .newsflash-details-header .header-right{
          position:absolute;
          right: 0.32rem;
          /*width: 0.32rem;*/
          height: 0.32rem;
      }
      .newsflash-details-header .header-right img {
          width: 0.32rem;
          height: 0.32rem;
      }

      /* 内容 */
      .newsflash-details-content {
        margin-top: 0.88rem;
        padding: 0 0.32rem ;
      }
      .newsflash-details-content .content-top {
        padding-bottom: 0.78rem;
      }
      .newsflash-details-content .content-top .content-top-text{
        padding-top: 0.18rem;
        padding-bottom: 0.24rem;
        font-family: PingFangSC-Regular;
        font-size: 0.32rem;
        letter-spacing: 0;
        text-align: juestify;
        line-height: 0.52rem;
        font-size: 16px;
        text-align: justify;
      }

      .newsflash-details-content .content-top .content-top-rate span:nth-child(1){
        /* width: 0.26rem; */
        height: 0.28rem;
        line-height: 0.28rem;
        display: inline-block;
        vertical-align: middle;
        color: #fff;
        background: #F86869;
        margin-right: 0.08rem;
        padding-left: 0.04rem;
        padding-right: 0.04rem;
      }
      .newsflash-details-content .content-top .content-top-rate span:nth-child(3) {
        font-family: DINAlternate-Bold;
        font-size: 0.24rem;
        color: #F75051;
        letter-spacing: 0;
        text-align: left;
        display: inline-block;
        vertical-align: middle;
      }
      .newsflash-details-content .content-middle {
        margin-bottom: 0.34rem;
      }

      .newsflash-details-content .content-bottom .time{
        position: absolute;
        top: 0;
        left: 0;
      }
      .newsflash-details-content .content-bottom .count{
        position: absolute;
        top: 0;
        right: 0;
      }

      .newsflash-details-content .info-detail-content-footer {
        margin-bottom: 0.42rem;
      }

      .newsflash-details-content .info-detail-content-footer-praise-box {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%,-50%);
      }
      .info-detail-content-footer-praise-box .box1 .img1,
      .info-detail-content-footer-praise-box .box1 .img2{
        width: 0.36rem;
        height: 0.36rem;
        /* display: none; */
      }
      .newsflash-details-content .info-detail-content-footer-pic {
        text-align: center;
        display: flex;
        justify-content: space-around;
        align-items: center;
      }
      .info-detail-content-footer-pic .pic {
        display: inline-block;
        flex: 1;
      }
      .info-detail-content-footer-pic .pic img{
        width: 0.64rem;
        height: 0.64rem;
      }
      /*  */
      .newsflash-details-header {
    width: 100%;
    height: 0.88rem;
    padding:0.28rem 0.32rem;
    position: fixed;
    top: 0;
    z-index: 999;
  }
  .newsflash-details-header .header-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.32rem;
    font-weight: 600;
    width: 2.56rem;
    text-overflow: -o-ellipsis-lastline;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box!important;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
  }
  .newsflash-details-content .content-top .content-top-rate{
    border-radius: 0.04rem;
    font-size: 0.2rem;
    display: inline-block;
    padding: 0.04em 0.12rem 0.04rem 0.08rem;
    margin-right: 0.1rem;
    margin-bottom: 0.1rem;
  }
  .newsflash-details-content .content-top .content-top-rate span:nth-child(2) {
    font-family: PingFangSC-Regular;
    font-size: 0.24rem;
    letter-spacing: 0;
    text-align: left;
    display: inline-block;
    vertical-align: middle;
    margin-right: 0.14rem;
  }
  .newsflash-details-content .content-middle .content-middle-time {
    font-family: PingFangSC-Regular;
    font-size: 0.24rem;
    letter-spacing: 0;
    text-align: left;
    margin-bottom: 0.2rem;
  }
  .newsflash-details-content .content-middle .content-middle-text{
    font-family: PingFangSC-Regular;
    font-size: 0.3rem;
    letter-spacing: 0;
    text-align: left;
    line-height: 0.48rem;
  }
  .newsflash-details-content  .content-bottom{
    height: 0.34rem;
    position: relative;
    font-family: PingFangSC-Regular;
    font-size: 0.24rem;
    margin-bottom: 0.68rem;
  }
  .newsflash-details-content .info-detail-content-lastText {
    font-family: PingFangSC-Regular;
    font-size: 0.24rem;
    letter-spacing: 0;
    text-align: justify;
    line-height: 0.36rem;
    margin-bottom: 0.48rem;
  }
  .newsflash-details-content .info-detail-content-footer-praise {
    width: 1.2rem;
    height: 1.2rem;
    border-radius: 50%;
    margin:0 auto;
    position: relative;
  }
  .newsflash-details-content .info-detail-content-footer-praise-box .box2{
    text-align: center;
    font-size: 0.2rem;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    line-height: 0.28rem;
  }
  .newsflash-details-content .info-detail-content-footer-desc {
    text-align: center;
    margin-top: 0.12rem;
    margin-bottom: 0.26rem;
    font-size: 0.24rem;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    line-height: 0.34rem;
  }
  .info-detail-comment-title {
    height: 0.82rem;
    font-size: 0.36rem;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    line-height: 0.5rem;
    padding-bottom: 0.32rem;
  }
  .info-detail-footer {
    width: 100%;
    padding: 0.2rem 0.32rem 0.2rem;
    position: fixed;
    bottom: 0;
    display: flex;
    align-items: end;
  }
  .info-detail-footer input{
    width: 100%;
    /* 4.68rem; */
    height: 0.6rem;
    border-radius: 0.8rem;
    padding-top: 0.12rem;
    padding-bottom: 0.12rem;
    padding-left: 0.28rem;
    margin-right: 0.3rem;
    font-size: 0.26rem;
  }
  .info-detail-footer .mainfooter {
    white-space: nowrap;
  }
  .info-detail-footer .mainfooter .footer-confirm {
    line-height: .6rem;
  }
  .info-detail-content-title {
    font-size: 0.44rem;
    font-family: PingFangSC-Semibold, PingFang SC;
    font-weight: 600;
    line-height: 0.62rem;
    margin-bottom: 0.12rem;
    /* padding: 0 0.4rem; */
    padding: 0;
    word-wrap: break-word;
  }
  .info-detail img {
    width: 100%;
  }
  .info-detail-content-subtitle {
    height: auto;
    font-size: 0.26rem;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    /* line-height: 0.36rem; */
    padding: 0;
  }
  /* 调整换行间距 */
  .content-top-text br > br {
    display: block;
    content: '';
    margin-top: 0.28rem;
  }
  </style>
</head>
<!--尽量不要在body上添加样式，除了背景色-->
<body>
<div>
  <!--具体代码-->

  <!-- 头部 -->
  <div class="newsflash-details-header">
    <div class="header-left">
        <img src="../../images/allPic/jiantou.png" alt="" onclick='closeWindow()' class="headerimg">
    </div>
    <div class="header-title">
      <!-- 我是文章的主标题哈哈哈哈哈 -->
    </div>
    <div class="header-right">
        <img style="height:0.34rem;width:0.34rem; margin-right: 8px;" src="../../images/jubao.jpg" onclick="report()" />
        <img src="../../images/allPic/fenxiang.png" alt=""  onclick="goShare()" class="headerimg1">
    </div>
  </div>

   <!-- 内容 -->
   <div class="fixed-content">
    <div class="newsflash-details-content">
      <div class="content-top"></div>
      <div class="content-middle"></div>
      <!-- <div class="content-bottom"></div> -->
      <!-- <div class="info-detail-content-lastText">
        <span>声明:文章内容仅供参，不构成投资建议。投资者据此操作，风险自担。</span>
      </div> -->
      <div class="info-detail-content-footer"></div>
    </div>


      <!-- 评论 -->
      <div class="info-detail-comment">
        <div class="info-detail-comment-title"></div>
        <div class="info-detail-comment-content">
          <ul></ul>
        </div>
      </div>
    </div>


    <!-- 底部 -->
    <div class="info-detail-footer">
      <input type="text" placeholder="" class="commentInpt">
      <div style='display:inline-block;vertical-align: middle;' class="mainfooter"></div>
    </div>


</div>
</body>
<!--下面五个文件为固定引用，自己根据情况调整路径，不要跟换引入顺序，其他引用添加在后面-->
<script src="../../js/dict.js"></script>
<script src="../../js/jquery-3.4.1.min.js"></script>
<script src="../../js/checkJsBridge.js"></script>
<script src="../../js/utils.js"></script>
<script src="../../js/api.js"></script>

<!--protobuf-->
<script src="../../js/protobuf.min.js"></script>
<script src="../../js/proto.js"></script>
<!--固定引用结束-->
<!--避免一个页面包含过多功能，减少js重绘页面，推荐分功能，分页面-->
<script>
  let level = 1 // 1:一级评论 2:二级评论
  let commentObjectId
  let isopencomment
  let infoType
  let token
  //初始关注状态
  let followStatus
  let pageNum = 1
  // 存储股票关键词
  let rateList = []
  //涨跌幅的结果
  let result
  //是否可评论
  let isComment = ''
  //分享的图片地址
  let imgUrl = ''
  /*固定页面初始化方法，用于替代$(function(){}),param为url参数，Object类型*/
  function initPage(params) {
    // params.infoId = '01c1650388c24f29ab98a02ac3996a6f'
    commentObjectId = params.infoId
    infoType = params.infoType

    //设置深色模式
    if(configColorType === '1'){
        $('.headerimg').attr('src','../../images/allPic/blackfanhui.png')
        $('.headerimg1').attr('src','../../images/allPic/blackfenxiang.png')
    }else{
        $('.headerimg').attr('src','../../images/allPic/jiantou.png')
        $('.headerimg1').attr('src','../../images/allPic/fenxiang.png')
    }

    if(params.isopencomment){
      isopencomment = params.isopencomment
    }else{
      isopencomment = '0'
    }
    // console.log(params)
    getinfoDetail(params)
    // getinfoDetail()
    $('.info-detail-comment-content ul').empty()
    // getcomment({'infoId':params.infoId,'pageNum':pageNum})
    // getcomment({'infoId':'01c1650388c24f29ab98a02ac3996a6f','pageNum':pageNum})
    //页面加载获取token用于判断是否可以评论或者点赞
    jsBridge.getData('token').then(res => {
      // console.log(res)
      token = res
      // token = '1111'
    })
  }

  /*页面所在窗口由后台前台时触发的方法,param为url参数，Object类型*/
  function startPage(params) {


  }

  //点击文章里面的举报
  function report() {
      jsBridge.showReportDialog({infoId: commentObjectId, infoType: '7'})
  }

  function reLoadPage() {
    jsBridge.getData('token').then(res => {
      // console.log(res)
      token = res
      // token = '1111'
    })
    $('.info-detail-comment-content ul').empty()
    pageNum = 1
    getcomment({'pageNum':pageNum,'infoId':commentObjectId})
  }
  // 阅读数格式化
  function formatReadCount(readTempCnt) {
    const num = parseFloat(readTempCnt);
    if (num === '' || num === null || num === undefined) return
    if (num < 1000) {
      return num.toFixed(0)
    }else if (num < 10000) {
      return Math.floor((num/1000) * 10) / 10 + "K+"
    }else {
      return Math.floor((num/10000) * 10) / 10 + "W+"
    }
  }
  // 匹配/n 换行符
  function replaceNewline(text) {
    // 强制转换为字符串，避免因非字符串输入报错（如 null、undefined、数字等）
    const processedText = String(text || ''); 
    // 匹配连续的换行符，动态替换为等量 <br>
    return processedText.replace(/\n+/g, (match) => '<br>'.repeat(match.length));
  }
  //获取资讯详情页面
  function getinfoDetail(params){
    Server.newsflash.newsflashdetails({'infoId':params.infoId}).then(res => {
    // Server.newsflash.newsflashdetails({'infoId':'01c1650388c24f29ab98a02ac3996a6f'}).then(res => {

      $('.content-top').empty()
      $('.content-middle').empty()
      $('.content-bottom').empty()
      $('.info-detail-content-footer').empty()
      $('.mainfooter').empty()
      console.log(res)
      if(res.code === 0){
        //图片为分享的图片地址，但是可能第一次获取为空，需要做二次判断
        imgUrl = res.data.detailImgUrl

        
        //做是否可评论即是否显示评论列表
        isComment = res.data.isComment
        if(isComment === '0'){
          // return false
          $('.info-detail-comment-title').hide()
          $('.commentInpt').attr("disabled",true);
          $('.commentInpt').attr("placeholder",'暂不支持评论');
        }else{
          $('.commentInpt').attr("placeholder",'说说你的看法');
          getcomment({'infoId':commentObjectId,'pageNum':pageNum})
        }
        //
        let data = res.data
        let creatTime = data.issuerDttm*1000
        let nowTime = +new Date().valueOf()
        let year = new Date(creatTime).getFullYear()
        let month = new Date(creatTime).getMonth()+1<10?'0'+(new Date(creatTime).getMonth()+1):new Date(creatTime).getMonth()+1
        let day = new Date(creatTime).getDate()<10?'0'+new Date(creatTime).getDate():new Date(creatTime).getDate()
        let hour = new Date(creatTime).getHours()<10?'0'+ new Date(creatTime).getHours(): new Date(creatTime).getHours()
        let minute = new Date(creatTime).getMinutes()<10?'0'+new Date(creatTime).getMinutes():new Date(creatTime).getMinutes()
        if(nowTime - creatTime < 30*60*1000){
          if(nowTime - creatTime < 1*60*1000){
            data.issuerDttm ='刚刚'
          }else{
            data.issuerDttm = parseInt((nowTime - creatTime)/1000/60)+'分钟前'
          }
        }else if(nowTime - creatTime < 24*60*60*1000){
            if(nowTime-creatTime < 60*60*1000){
              data.issuerDttm = '1小时前'
            }else {
              data.issuerDttm = parseInt((nowTime - creatTime)/1000/60/60)+'小时前'
            }
        }else if(new Date().getDate()-new Date(creatTime).getDate()==1 && new Date().getMonth()==new Date(creatTime).getMonth() && new Date().getFullYear() == new Date(creatTime).getFullYear()){
          data.issuerDttm = '昨天'+hour+":"+minute
        }else{
          data.issuerDttm = year+'-'+ month+'-'+day+' '+hour+':'+minute
        }
        let date = new Date().getFullYear() === year ? month+'-'+day+' '+hour+':'+minute : year+'-'+ month+'-'+day+' '+hour+':'+minute
        let authors = data.characterName ? data.characterName : ''
        
        let partThree =
          `<div class="info-detail-content-title">
              <span>${data.mainTitle}</span>
            </div>
          <div class="info-detail-content-subtitle" style="color: rgba(34, 34, 34, 0.45);">
            <span>${authors}</span>
            <span>${date}</span>
            <span>${formatReadCount(data.readCnt)}阅读</span>
          </div>
          `
          $('.content-top').append(partThree)
        // let authorHtml = '';
        // authors.forEach(item => {
        //   authorHtml = `<span style="color:#7D430A;margin-right: 4px;">${item}</span>`
        //   $('.info-detail-content-subtitle').prepend(authorHtml)
        // })
        // style="color:${data.isRecommend ==='0'?'#333333':'#C7000B'
        let rawContent = data.content; 
        // CSS white-space: pre-wrap;word-break: break-word;
        let top =
            `<div class="content-top-text" style="color:#333333;white-space: pre-wrap;word-break: break-word;">${rawContent}</div>`
         $('.content-top').append(top)
         if(data.hcontentUrl){
           let img =
             `<div class="info-detail">
               <img src="${data.hcontentUrl}" alt="">
             </div>`
           $('.content-top').append(img)
         }
         if(data.scontentUrl){
           let img =
             `<div class="info-detail">
               <img src="${data.scontentUrl}" alt="">
             </div>`
           $('.content-top').append(img)
         }
        //关键词
        if(res.data.keyWords){
          let keyWords = JSON.parse(res.data.keyWords)
          if(keyWords.length !== 0){

            rateList = keyWords.filter((v,i) => {
              return v['type-url'].split(':')[0] === '2' || v['type-url'].split(':')[0] === '6'
            })
            console.log(rateList,'rateListrateListrateList')

            let listContract = {
                listContract: [
                  {
                    //exchangeNo: 'SH',
                    //commodityNo: '000001',
                    //commodityType: 'S',
                    //contractNo: '9999'
                  }
                ]
              }
              listContract.listContract = []

              //保存需要的数据方便后面的股票跳转渲染
              listArr =  []

              rateList.map((v,i) => {
                let it = v['type-url'].split('.')
                let obj = {}
                obj.commodityNo = it[0][0] === '2'?it[1]:it[0].split(':')[1]
                obj.commodityType = it[2]
                obj.contractNo = '9999'
                obj.exchangeNo = it[0][0] === '2'?it[0].split(':')[1]:it[1]
                listContract.listContract.push(obj)
                listArr.push(obj)
              })
              // console.log(listContract,'listContract')
              // console.log(listArr,'listArrlistArrlistArr')


              const buf = protoBuf.encodeToBase64('GetSnapshotRequest', listContract)
              Server.realTimeInfo.getRatePoint({request: buf}).then(res => {
                console.log(res,'resresres')
                result = protoBuf.decodeFromBase64('GetSnapshotResponse', res.data)
                // console.log(result,'resultresultresult')

                  result.listSnapshot.map((item,index) => {
                  rateList[index].changeRate = item.changeRate?item.changeRate*1000000/10000+'%':'0.00%'
                })

                  listArr.map((item,index) => {
                    rateList[index].uniqueCode = item.exchangeNo
                    rateList[index].code = item.commodityNo
                  })

                console.log(rateList,'rateListrateListrateList')
                rateList.map((item,index) => {
                  let keyWords =
                            `<div class="content-top-rate" onclick="gogupiao(gogupiao({'exchange':'${item.uniqueCode}','code':'${item.code}'}))">
                              <span style="background:${item.uniqueCode === 'SZ'?'#568BF9':'#F04D4E'}">${item.uniqueCode}</span><span>${item.key}</span><span style="color:${item.changeRate[0] === '-'?'#00AE1F':'#F04D4E'}">${item.changeRate[0] === '-'?item.changeRate:('+'+item.changeRate)}</span>
                            </div>`

                        $('.content-top').append(keyWords)
                  })
              })

          }
        }

        //修改时间（快讯快评时间和发布时间）
        // let creatTime = data.issuerDttm*1000
        // let nowTime = +new Date().valueOf()
        // let year = new Date(creatTime).getFullYear()
        // let month = new Date(creatTime).getMonth()+1<10?'0'+(new Date(creatTime).getMonth()+1):new Date(creatTime).getMonth()+1
        // let day = new Date(creatTime).getDate()<10?'0'+new Date(creatTime).getDate():new Date(creatTime).getDate()
        // let hour = new Date(creatTime).getHours()<10?'0'+ new Date(creatTime).getHours(): new Date(creatTime).getHours()
        // let minute = new Date(creatTime).getMinutes()<10?'0'+new Date(creatTime).getMinutes():new Date(creatTime).getMinutes()
        // if(nowTime - creatTime < 30*60*1000){
        //   if(nowTime - creatTime < 1*60*1000){
        //     data.issuerDttm ='刚刚'
        //   }else{
        //     data.issuerDttm = parseInt((nowTime - creatTime)/1000/60)+'分钟前'
        //   }
        // }else if(nowTime - creatTime < 24*60*60*1000){
        //     if(nowTime-creatTime < 60*60*1000){
        //       data.issuerDttm = '1小时前'
        //     }else {
        //       data.issuerDttm = parseInt((nowTime - creatTime)/1000/60/60)+'小时前'
        //     }
        // }else if(new Date().getDate()-new Date(creatTime).getDate()==1 && new Date().getMonth()==new Date(creatTime).getMonth() && new Date().getFullYear() == new Date(creatTime).getFullYear()){
        //   data.issuerDttm = '昨天'+hour+":"+minute
        // }else{
        //   data.issuerDttm = year+'-'+ month+'-'+day+' '+hour+':'+minute
        // }
        //
        let creatTime1 = data.commentContentDt*1000
        let nowTime1 = +new Date().valueOf()
        let year1 = new Date(creatTime1).getFullYear()
        let month1 = new Date(creatTime1).getMonth()+1<10?'0'+(new Date(creatTime1).getMonth()+1):new Date(creatTime1).getMonth()+1
        let day1 = new Date(creatTime1).getDate()<10?'0'+new Date(creatTime1).getDate():new Date(creatTime1).getDate()
        let hour1 = new Date(creatTime1).getHours()<10?'0'+ new Date(creatTime1).getHours(): new Date(creatTime1).getHours()
        let minute1 = new Date(creatTime1).getMinutes()<10?'0'+new Date(creatTime1).getMinutes():new Date(creatTime1).getMinutes()
        if(nowTime1 - creatTime1 < 30*60*1000){
          if(nowTime1 - creatTime1 < 1*60*1000){
            data.commentContentDt ='刚刚'
          }else{
            data.commentContentDt = parseInt((nowTime1 - creatTime1)/1000/60)+'分钟前'
          }
        }else if(nowTime1 - creatTime1 < 24*60*60*1000){
            if(nowTime1-creatTime1 < 60*60*1000){
              data.commentContentDt = '1小时前'
            }else {
              data.commentContentDt = parseInt((nowTime1 - creatTime1)/1000/60/60)+'小时前'
            }
        }else if(new Date().getDate()-new Date(creatTime1).getDate()==1 && new Date().getMonth()==new Date(creatTime1).getMonth() && new Date().getFullYear() == new Date(creatTime1).getFullYear()){
          data.commentContentDt = '昨天'+hour1+":"+minute1
        }else{
          data.commentContentDt = year1+'-'+ month1+'-'+day1+' '+hour1+':'+minute1
        }

        let middle =
              `<div class="content-middle-time" style="display:${data.commentContent?'block':'none'}">${data.commentContentDt}</div>
            <div class="content-middle-text" style="display:${data.commentContent?'block':'none'}">
              ${data.commentContent}
            </div>`

        let bottom =
              `<span class="time">${data.issuerDttm}</span>
              <span class="count">${data.readCnt}人查看</span>`

        let textfooter =
        `<div class="info-detail-content-lastText">
          <span>声明：文章内容仅供参考，不构成投资建议。投资者据此操作，风险自担。</span>
        </div>
        <div class="info-detail-content-footer-praise">
          <div class="info-detail-content-footer-praise-box">
            <div class="box1">
              <img src="${configColorType==='1'?'../../images/allPic/blackdianzan.png':'../../images/allPic/nodianzan1.png'}" alt="" data-status='1' class="img1" style="display:${data.thumbsupStatus==='0'?'block':'none'}" onclick="zxupdatePriase1({'thumbupObjectId':'${data.infoId}','status':'${data.thumbsupStatus==='0'?'1':'0'}'},this)">
              <img src="../../images/allPic/yidianzan1.png" alt="" data-status='0' class="img1" style="display:${data.thumbsupStatus==='1'?'block':'none'}" onclick="zxupdatePriase1({'thumbupObjectId':'${data.infoId}','status':'${data.thumbsupStatus==='1'?'0':'1'}'},this)">
            </div>
            <div class="box2">${data.thumbsupCnt}</div>
          </div>
        </div>

        <div class="info-detail-content-footer-desc">
          好文章，需要你的鼓励
        </div>

        <div class="info-detail-content-footer-pic">
          <div class="pic2 pic">

          </div>
          <div class="pic1 pic">
            <img src="${configColorType==='1'?'../../images/allPic/blackpyq.png':'../../images/allPic/pengyouquan.png'}" alt="" onclick="sharepyq()">
          </div>
          <div class="pic2 pic">
            <img src="${configColorType==='1'?'../../images/allPic/blackweixin.png':'../../images/allPic/weixin@2x.png'}" alt="" onclick="sharewx()">
          </div>
          <div class="pic2 pic">

          </div>
        </div>`

        let footer =
        `<div class="footer-noconfirm" id='footer-noconfirm'  style="display:${isopencomment==='0'?'block':'none'};padding-left:0.4rem;">
            <div class="comment">
              <img src="${configColorType==='1'?'../../images/allPic/blackpinglun.png':'../../images/allPic/dapinglun.png'}" alt="" onclick="commentFocus()">
            </div>
            <div class="praise">
              <img src="${configColorType==='1'?'../../images/allPic/blackdianzan.png':'../../images/allPic/danodianzan.png'}" alt="" data-status='1' style="display:${data.thumbsupStatus === '0'?'block':'none'}" onclick="zxupdatePriase2({'thumbupObjectId':'${data.infoId}','status':'${data.thumbsupStatus==='0'?'1':'0'}'},this)">
              <img src="../../images/allPic/dayidianzan.png" alt="" data-status='0' style="display:${data.thumbsupStatus === '1'?'block':'none'}" onclick="zxupdatePriase2({'thumbupObjectId':'${data.infoId}','status':'${data.thumbsupStatus==='1'?'0':'1'}'},this)">
            </div>
            <!--  <div class="collect">
              <img src="../../images/allPic/noshoucang.png" alt="" data-status='1' style="display:${data.collectionStatus === '0'?'block':'none'}" onclick="updateCollect({'collectionObjectId':'${data.infoId}','status':'${data.collectionStatus==='0'?'1':'0'}'},this)">
              <img src="../../images/allPic/yishoucang.png" alt="" data-status='0' style="display:${data.collectionStatus === '1'?'block':'none'}" onclick="updateCollect({'collectionObjectId':'${data.infoId}','status':'${data.collectionStatus==='1'?'0':'1'}'},this)">
            </div> -->
        </div>
        <div class="footer-confirm" id='footer-confirm' style="display:${isopencomment==='0'?'none':'block'};padding-left:0.4rem;" onclick="sendcomment()">发送</div>`

          $('.content-middle').append(middle)
          // $('.content-bottom').append(bottom) // 时间 跟阅读数，底部的不要了
          $('.info-detail-content-footer').append(textfooter)
          $('.mainfooter').append(footer)


      }else{
        // jsBridge.toast('数据异常')
      }
    })
  }
  //获取资讯详情页面的全部一级评论
  function getcomment(params){
    Server.informationcommentList.getComment({'pageNum':params.pageNum,'pageSize':5,'commentObjectId':params.infoId,'datasource':'1'}).then(res => {
    // Server.informationcommentList.getComment({'pageNum':params.pageNum,'pageSize':5,'commentObjectId':'01c1650388c24f29ab98a02ac3996a6f','datasource':'1'}).then(res => {
      console.log(res,'comment')
      if(res.code === 0){
        $('.info-detail-comment-title').empty()
        let list = res.data
        let count = `<span>全部评论（${res.commentTotal}）</span>`
        $('.info-detail-comment-title').append(count)

        list.map((item,index) => {
            //修改时间
            let creatTime = item.createDttm*1000
            let nowTime = +new Date().valueOf()
            let year = new Date(creatTime).getFullYear()
            let month = new Date(creatTime).getMonth()+1<10?'0'+(new Date(creatTime).getMonth()+1):new Date(creatTime).getMonth()+1
            let day = new Date(creatTime).getDate()<10?'0'+new Date(creatTime).getDate():new Date(creatTime).getDate()
            let hour = new Date(creatTime).getHours()<10?'0'+ new Date(creatTime).getHours(): new Date(creatTime).getHours()
            let minute = new Date(creatTime).getMinutes()<10?'0'+new Date(creatTime).getMinutes():new Date(creatTime).getMinutes()
            if(nowTime - creatTime < 30*60*1000){
              if(nowTime - creatTime < 1*60*1000){
                item.createDttm = '刚刚'
              }else{
                item.createDttm = parseInt((nowTime - creatTime)/1000/60)+'分钟前'
              }
            }else if(nowTime - creatTime < 24*60*60*1000){
                if(nowTime-creatTime < 60*60*1000){
                  item.createDttm = '1小时前'
                }else {
                  item.createDttm = parseInt((nowTime - creatTime)/1000/60/60)+'小时前'
                }
            }else if(new Date().getDate()-new Date(creatTime).getDate()==1 && new Date().getMonth()==new Date(creatTime).getMonth() && new Date().getFullYear() == new Date(creatTime).getFullYear()){
              item.createDttm = '昨天'+hour+":"+minute
            }else{
              item.createDttm = year +'-'+ month+'-'+day+' '+hour+':'+minute
            }
        })

        list.map((v,i) => {
          let li =
                `<li onclick="gocomment('${v.userName}', '${v.commentId}')">
                  <div class='comstatus' style="display:${v.status==='2'?'block':'none'}">审核中</div>
                  <div class="comment-content-left">
                    <img src="${v.headUrl?v.headUrl:'../../images/allPic/touxiang.png'}" alt="">
                  </div>
                  <div class="comment-content-right">
                    <div class="name">${v.userName}
                      <span style="display:${(v.isTop === '1') ? 'inline-block' : 'none'}" class="comment-isTop">精选</span>
                    </div>
                    <div class="explain">${v.content}</div>

                    <div class="litterIcon">
                      <div style="position:absolute;left:0;">
                        <span style="color: rgba(0, 0, 0, 0.4);">${v.createDttm}</span>
                        <span style="color: rgba(0, 0, 0, 0.65);margin-left: .25rem;" onclick="sendComment(event, '${v.userName}', '${v.commentId}')">回复</span>
                      </div>
                    </div>
                    <div class="secondcomment-seeAll" style="display:${(v.status === '1' && v.childCount !== 0)?'block':'none'}">
                      <span onclick="dosecondcomment(event, {'datasource':'1','isopencomment':'0','parentId':'${v.commentId}','commentObjectId':'${commentObjectId}'})">查看全部评论(${v.childCount})条></span>
                    </div>
                  </div>
                  <div class="comment-content-right-r">
                    <div style="display:${v.status === '2' ? 'none' : 'block'}" class="iconBox">

                      <span style='vertical-align:middle;'>
                        <img src="${configColorType === '1' ? '../../images/allPic/blackdianzan.png' : '../../images/allPic/nodianzan1.png'}" alt="" data-status='1' style="display:${v.ifThumbsup === '0' ? 'block' : 'none'}" onclick="commentPriase({'thumbupObjectId':'${v.commentId}','status':'${v.ifThumbsup === '0' ? '1' : '0'}'},this)">
                        <img src="../../images/allPic/yidianzan1.png" alt="" data-status='0' style="display:${v.ifThumbsup === '1' ? 'block' : 'none'}" onclick="commentPriase({'thumbupObjectId':'${v.commentId}','status':'${v.ifThumbsup === '1' ? '0' : '1'}'},this)">
                      </span>
                      <span style='vertical-align:middle;'>${v.thumbsupCnt}</span>
                    </div>
                  </div>
                </li>`
            $('.info-detail-comment-content ul').append(li)
        })
      }else{
        // jsBridge.toast('数据异常')
      }
    })
  }
  //点击文章内部点赞按钮（文章点赞）
  function zxupdatePriase1(params1,params2){
    console.log(params1,params2)
    if(token){
        let status = $(params2).attr('data-status')
        // console.log($('.praise img'),'child')
        if(status === '1'){
          let num = $(params2).parent().next().text()
          $(params2).parent().next().text(+num+1)
          $('.praise img').eq(0).hide().siblings().show()
        }else{
          let num = $(params2).parent().next().text()
          $(params2).parent().next().text(+num-1)
          $('.praise img').eq(1).hide().siblings().show()
        }
        $(params2).hide().siblings().show()
        Server.realTimeInfo.updatePriase({'thumbupObjectId':params1.thumbupObjectId,'datasource':'1','status':params1.status,'objectSource':'1','source':'3'}).then(res => {
        console.log(res,'updatePriase')
        if(res.code === 0){
          // getinfoDetail({'infoId':commentObjectId,'infoType':infoType})
        }else if(res.code === -8){
          // jsBridge.toast(res.data.msg)
          // jsBridge.openLogin()
          jsBridge.delData('token')
          token = ''
          jsBridge.toast('登录过期，请重新登录')
        }else{

        }
      })
    }else{
      // jsBridge.toast('暂未登录,请先登录...')
      jsBridge.openLogin()
    }
  }
  //底部点赞按钮（文章点赞）
  function zxupdatePriase2(params1,params2){
    console.log(params1,params2)
    if(token){
      let status = $(params2).attr('data-status')
      if(status === '1'){
        $('.info-detail-content-footer-praise-box .box1 img').eq(0).hide().siblings().show()
        let num = $('.info-detail-content-footer-praise-box .box1').siblings().text()
        $('.info-detail-content-footer-praise-box .box1').siblings().text(+num+1)
      }else{
        $('.info-detail-content-footer-praise-box .box1 img').eq(1).hide().siblings().show()
        let num = $('.info-detail-content-footer-praise-box .box1').siblings().text()
        $('.info-detail-content-footer-praise-box .box1').siblings().text(+num-1)
      }
      $(params2).hide().siblings().show()
        Server.realTimeInfo.updatePriase({'thumbupObjectId':params1.thumbupObjectId,'datasource':'1','status':params1.status,'objectSource':'1','source':'3'}).then(res => {
        console.log(res,'updatePriase')
        if(res.code === 0){
          // getinfoDetail({'infoId':commentObjectId,'infoType':infoType})
        }else if(res.code === -8){
          // jsBridge.toast(res.data.msg)
          // jsBridge.openLogin()
          jsBridge.delData('token')
          token = ''
          jsBridge.toast('登录过期，请重新登录')
        }else{

        }
      })
    }else{
      // jsBridge.toast('暂未登录,请先登录...')
      jsBridge.openLogin()
    }
  }
  // 评论回复
  function sendComment (event, username, pid) {
    // console.log(event)
    // token = '3de7dae4593ccf0d86b0a6230fb23e99'
    if(token){
      parentId = pid
      // console.log('parentId', parentId, pid)
      level = 2
      $('.commentInpt').attr("placeholder", '回复' + username)
      isopencomment = '1'
      $('.commentInpt').focus()
    }else{
      // jsBridge.toast('暂未登录，请先登录...')
      jsBridge.openLogin()
    }
  }
  //点击评论里面的点赞按钮
  function commentPriase(params1,params2){
    event.stopPropagation()
    // console.log(params1,params2)
    if(token){
        let status = $(params2).attr('data-status')
        if(status === '1'){
          let num = $(params2).parent().next().text()
          $(params2).parent().next().text(+num+1)
        }else{
          let num = $(params2).parent().next().text()
          $(params2).parent().next().text(+num-1)
        }
        $(params2).hide().siblings().show()
        Server.realTimeInfo.updatePriase({'thumbupObjectId':params1.thumbupObjectId,'datasource':'1','status':status,'objectSource':'1','source':''}).then(res => {
        console.log(res,'commentPriase')
        if(res.code === 0){
          // getcomment({'infoId':commentObjectId})
        }else if(res.code === -8){
          // jsBridge.toast(res.data.msg)
          // jsBridge.openLogin()
          jsBridge.delData('token')
          token = ''
          jsBridge.toast('登录过期，请重新登录')
        }else{

        }
      })
    }else{
      // jsBridge.toast('暂未登录,请先登录...')
      jsBridge.openLogin()
    }
  }
  //点击底部的收藏按钮
  function updateCollect(params1,params2){
    console.log(params1,params2)
    if(token){
      let status = $(params2).attr('data-status')
      $(params2).hide().siblings().show()
        Server.realTimeInfo.updateCollectdata({'collectionObjectId':params1.collectionObjectId,'datasource':'1','status':status,'objectSource':'1'}).then(res => {
        console.log(res,'updatecollect')
        if(res.code === 0){
          // getinfoDetail({'infoId':commentObjectId,'infoType':infoType})
        }else{
          jsBridge.toast(res.data.msg)
        }
      })
    }else{
      // jsBridge.toast('暂未登录,请先登录...')
      jsBridge.openLogin()
    }
  }
  //点击播放按钮播放音频
  function playvioce(params1,params2){
    console.log(params1,params2)
    // params1.voiceUrl = 'https://pi.fan-x.fun:666/www/music/3.mp3'
    jsBridge.openInfoVoice({'voiceUrl':params1.voiceUrl,'mainTitle':params1.mainTitle,'infoType':params1.infoType,'infoId':params1.infoId,'coverImgUrl':params1.coverImgUrl})
  }
  //点击评论小图标
  function commentFocus(){
    if(isComment === '0'){
      return false
    }else{
      $('.commentInpt').focus()
    }
  }
  //点击发送按钮
  function sendcomment(){
    // token = '3de7dae4593ccf0d86b0a6230fb23e99'
    if(token){
      let content = $('.commentInpt').val()
      if(content === ''){
        jsBridge.toast('内容不为空')
      }else{
        Server.informationcommentList.addcomment({'parentId': level == 2 ? parentId : '0','commentObjectId':commentObjectId,'content':content,'datasource':'1','objectSource':'1'}).then(res => {
          console.log(res)
          if(res.code === 0){
            // jsBridge.toast('评论成功')
            jsBridge.toast('评论成功，审核通过后将展示在评论区哦~')
            $('.commentInpt').val('')
            $('.commentInpt').attr("placeholder", '请说说你的看法...')
            $('.info-detail-comment-content ul').empty()
            pageNum = 1
            getcomment({'infoId':commentObjectId,'pageNum':pageNum})
            $('.commentInpt').blur()
            level = 1
          }else if(res.code === -8){
            // jsBridge.toast('数据异常')
            jsBridge.delData('token')
            token = ''
            jsBridge.toast('登录过期，请重新登录')
          }else{

          }
        })
      }
    }else{
      // jsBridge.toast('暂未登录,请先登录...')
      jsBridge.openLogin()
    }
  }
  //input框聚焦失焦,加定时器确保点击事件先触发
  $('.commentInpt').blur(function(){
    setTimeout(function(){
      $('#footer-noconfirm').show()
      $('#footer-confirm').hide()
    },100)
  })
  $('.commentInpt').focus(function(){
    setTimeout(function(){
      $('#footer-noconfirm').hide()
      $('#footer-confirm').show()
    },100)
  })
  //从资讯详情页的评论点击回复做二级评论,唤起输入框
  function dosecondcomment(e, params){
    // console.log(params)
    if(e.stopPropagation) { //W3C阻止冒泡方法
        e.stopPropagation();
    } else {
        e.cancelBubble = true; //IE阻止冒泡方法
    }
    if(token){
      jsBridge.openWindow('/html/comment/commentdetails.html?parentId='+params.parentId+'&datasource=1'+'&isopencomment='+params.isopencomment+'&commentObjectId='+params.commentObjectId,{}, {noBar: false})
    }else{
      // jsBridge.toast('暂未登录，请先登录...')
      jsBridge.openLogin()
    }
  }
  //去评论详情页但是不换起输入框
  function gocomment(username, pid){
    if(token){
      parentId = pid
      level = 2
      // $('.level1 .commentInpt').val('@'+username+' ')
      $('.commentInpt').attr("placeholder", '回复' + username) // ;val('@'+username+' ')
      isopencomment = '1'
      $('.commentInpt').focus()
    }else{
      // jsBridge.toast('暂未登录，请先登录...')
      jsBridge.openLogin()
    }
    // jsBridge.openWindow('/html/comment/commentdetails.html?parentId='+params.parentId+'&datasource=1'+'&isopencomment='+params.isopencomment+'&commentObjectId='+params.commentObjectId,{}, {noBar: false})
  }
  //点击关注
  function follow(params1,params2){
    // console.log(params1,params2)
    if(token){
        let status = $(params2).attr('data-status')
        if(status === '1'){
          let num = $('.followCnt').text()
          console.log(num,'num')
          $('.followCnt').text(+num+1)
        }else{
          let num = $('.followCnt').text()
          console.log(num,'num')
          $('.followCnt').text(+num-1)
        }
        $(params2).hide().siblings().show()
        Server.realTimeInfo.updateFollow({'followObjectId':params1.follow_object_id,'datasource':'1','status':status,'objectSource':'6'}).then(res => {
        console.log(res,'update')
        if(res.code === 0){
          // $(params2).toggleClass('active')
          // getinfoDetail({'infoId':commentObjectId,'infoType':infoType})
        }else{
          // jsBridge.toast(res.data.msg)
        }
      })
    }else{
      // jsBridge.toast('暂未登录,请先登录...')
      jsBridge.openLogin()
    }
  }
  //点击返回按钮
  function closeWindow(){
    jsBridge.closeWindows()
  }
  //滑动加载下一页
  document.addEventListener('scroll',function(){
    //头部显示主标题
    let scroll = $(document).scrollTop()
    if(scroll !==0 ){
      let title = $('.content-top-text').text()
      $('.header-title').text(title)
    }else{
      $('.header-title').text('')
    }

    if(isComment === '0'){
      return false
    }else{
      let top = $('.info-detail-comment').offset().top
      let height = $('.info-detail-comment').height()+16
      let maxHeight = document.body.offsetHeight
      let scroll = $(document).scrollTop()

      // console.log(scroll,'scroll')
      // console.log(top,'top')
      // console.log(height,'height')
      // console.log(maxHeight,'maxHeight')
      // console.log(top+height+50-maxHeight,'top+height-maxHeight')
      if(Math.round(top+height+50-maxHeight) === Math.round(scroll) ){
        pageNum++
        getcomment({'infoId':commentObjectId,'pageNum':pageNum})
      }
    }
  })
  //点击股票跳转股票详情
  function gogupiao(params){
    jsBridge.openStock(params.exchange,params.code)
  }
  //分享
  function goShare(){
    event.stopPropagation()
    // jsBridge.toast('敬请期待')
    // if(!imgUrl){
    //   Server.newsflash.getnewsflashimg({'id':commentObjectId}).then(res => {
    //     if(res.code === 0){
    //       if(res.data.code === '1'){
    //         imgUrl = res.data.url
    //         jsBridge.share({'scene':'0,1','type':'image','image':imgUrl})
    //       }else{
    //         jsBridge.toast('暂不支持分享')
    //       }
    //     }else{
    //       jsBridge.toast('暂不支持分享')
    //     }
    //   })
    // }else{
    //   jsBridge.share({'scene':'0,1','type':'image','image':imgUrl})
    // }
    jsBridge.share({'scene':'0,1','type':'image','image':imgUrl})
    // if(imgUrl){
    //   jsBridge.share({'scene':'0,1','type':'image','image':imgUrl})
    // }else{
    //   jsBridge.toast('暂不支持分享')
    // }
  }
  //点击文章里面的分享微信或者分享朋友圈
  function sharewx(){
    // if(!imgUrl){
    //   Server.newsflash.getnewsflashimg({'id':commentObjectId}).then(res => {
    //     if(res.code === 0){
    //       if(res.data.code === '1'){
    //         imgUrl = res.data.url
    //         jsBridge.share({'scene':'0','type':'image','image':imgUrl})
    //       }else{
    //         jsBridge.toast('暂不支持分享')
    //       }
    //     }else{
    //       jsBridge.toast('暂不支持分享')
    //     }
    //   })
    // }else{
    //   jsBridge.share({'scene':'0','type':'image','image':imgUrl})
    // }
    jsBridge.share({'scene':'0','type':'image','image':imgUrl})
    // if(imgUrl){
    //   jsBridge.share({'scene':'0','type':'image','image':imgUrl})
    // }else{
    //   jsBridge.toast('暂不支持分享')
    // }
  }
  function sharepyq(){
    // if(!imgUrl){
    //   Server.newsflash.getnewsflashimg({'id':commentObjectId}).then(res => {
    //     if(res.code === 0){
    //       if(res.data.code === '1'){
    //         imgUrl = res.data.url
    //         jsBridge.share({'scene':'1','type':'image','image':imgUrl})
    //       }else{
    //         jsBridge.toast('分享超时，请稍后尝试!')
    //       }
    //     }else{
    //       jsBridge.toast('暂不支持分享')
    //     }
    //   })
    // }else{
    //   jsBridge.share({'scene':'1','type':'image','image':imgUrl})
    // }
    jsBridge.share({'scene':'1','type':'image','image':imgUrl})
    // if(imgUrl){
    //   jsBridge.share({'scene':'1','type':'image','image':imgUrl})
    // }else{
    //   jsBridge.toast('暂不支持分享')
    // }
  }
</script>
</html>
